package com.bw.lib_router

import android.content.Context
import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.facade.service.DegradeService
import com.bw.lib_base.path.RouterPath

/**
 * 全局页面跳转的降级策略
 */

@Route(path = RouterPath.GROUP_LOGIN)
class GlobalDegradeService:DegradeService {

    private lateinit var mContext:Context

    override fun init(context: Context?) {
        if (context!=null){
            mContext=context
        }
    }

    /**
     * 目标页面找不到的情况，会执行此方法
     */
    override fun onLost(context: Context, postcard: Postcard) {
        postcard.group=RouterPath.GROUP_EMPTY
        postcard.path=RouterPath.PATH_EMPTY_PAGE
        postcard.navigation()
    }
}